﻿using System;
using System.Security.Cryptography;
using System.Text;

namespace INHollandair.Core.Models
{
    public static class EncryptionUtils
    {
        public static string Salt()
        {
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            byte[] buff = new byte[32];
            rng.GetBytes(buff);
            return Convert.ToBase64String(buff);
        }

        public static string Hash(string password, string salt)
        {
            UnicodeEncoding uEncode = new UnicodeEncoding();
            byte[] b = uEncode.GetBytes(salt);

            Rfc2898DeriveBytes pbkdf2 = new Rfc2898DeriveBytes(password, b, 10000);
            return Convert.ToBase64String(pbkdf2.GetBytes(32));
        }
    }
}
